/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.beans;

import java.util.List;
import javax.faces.model.SelectItem;
import org.cip.esymons.tesoreria.be.TipoMoneda;
import org.cip.esymons.tramite.bc.TipoMonedaDelegate;

/**
 *
 * @author Cristian
 */
public class TipoMonedaController {

    private TipoMonedaDelegate delegado;

    public TipoMonedaController() {
        delegado=new TipoMonedaDelegate();
    }

    public TipoMoneda buscarPorCodigo(Long codigo) {
        try {
            return delegado.find(codigo);
        } catch (Exception ex) {
            return null;
        }
    }

    public SelectItem[] getTipoMonedaItem() {
        try {
            List<TipoMoneda> lc = delegado.findAll();
            SelectItem[] select = new SelectItem[lc.size()];
            int i = 0;
            for (TipoMoneda tm : lc) {
                SelectItem item = new SelectItem(tm, tm.getTmoDesc());
                select[i++] = item;
            }

            return select;
        } catch (Exception ex) {
            SelectItem[] select = new SelectItem[1];
            SelectItem item = new SelectItem(null, "No existen Tipo Moneda");
            select[0] = item;
            return select;
        }
    }

}
